package com.example.aicloud.config;


import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * xxl-job 配置文件： 将xxl-job 的执行器注入到Ioc容器中
 */
@Configuration
public class XxlJobConfig {
    @Value("${xxl.job.admin.address}")
    private String adminAddresses;
    @Value("${xxl.job.executor.appname}")
    private String appname;
    @Value("${xxl.job.accessToken}")
    private String accessToken;
    @Value("${server.port}")
    private int port;
    @Value("${xxl.job.executor.logpath}")
    private String logPath;
    @Value("${xxl.job.executor.logretentiondays}")
    private int logRetentionDays;

    @Bean
    public XxlJobSpringExecutor xxlJobExecutor() {
        XxlJobSpringExecutor executor = new XxlJobSpringExecutor();
        executor.setAdminAddresses(adminAddresses);
        executor.setAppname(appname);
        executor.setAccessToken(accessToken);
        executor.setPort(port+10000);
        executor.setLogPath(logPath);
        executor.setLogRetentionDays(logRetentionDays);
        System.out.println(">>>>>>>>>>> xxl-job config init.");
        return executor;
     }
}
